package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qf.mapper.DtsGoodsProductMapper;
import com.qf.pojo.DtsGoodsProduct;
import com.qf.service.DtsGoodsProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @version v1.0.0
 * @Description:
 * @author: 姜红凯
 * @date: 2022.02.23
 * @since 1.0
 */
@Service
public class DtsGoodsProductServiceImpl implements DtsGoodsProductService {

    @Autowired
    DtsGoodsProductMapper productMapper;

    @Override
    public List<DtsGoodsProduct> findById(Integer id) {
        LambdaQueryWrapper<DtsGoodsProduct> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DtsGoodsProduct::getGoodsId,id);
        wrapper.eq(DtsGoodsProduct::getDeleted,false);

        List<DtsGoodsProduct> products = productMapper.selectList(wrapper);
        return products;
    }

    @Override
    public void deleteByGoodsId(Integer goodId) {
        LambdaQueryWrapper<DtsGoodsProduct> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DtsGoodsProduct::getGoodsId,goodId);
        productMapper.delete(wrapper);

    }

    @Override
    public void insert(DtsGoodsProduct product) {
        productMapper.insert(product);
    }
}
